package com.ruoyi.system.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.WorkOthersResult;
import com.ruoyi.system.service.IWorkOthersResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 查看同系部成果Controller
 * 
 * @author ruoyi
 * @date 2024-08-07
 */
@RestController
@RequestMapping("/work/othersResult")
public class WorkOthersResultController extends BaseController
{
    @Autowired
    private IWorkOthersResultService workOthersResultService;

    /**
     * 查询他人成果列表
     */
    @PreAuthorize("@ss.hasPermi('work:othersResult:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkOthersResult workOthersResult) {
        Long userId = getLoginUser().getUserId();
        System.out.println("-------------判断是否为管理员:" + SecurityUtils.isAdmin(userId));
        System.out.println("-------------查看登录用户部门id:" + getLoginUser().getDeptId());
        if (SecurityUtils.isAdmin(userId)) {
            startPage();
            List<WorkOthersResult> list = workOthersResultService.selectWorkOthersResultList(workOthersResult);
            return getDataTable(list);
        } else {
            startPage();
            workOthersResult.setDeptId(getLoginUser().getDeptId());
            List<WorkOthersResult> list = workOthersResultService.selectWorkOthersResultList(workOthersResult);
            return getDataTable(list);
        }
    }


}
